<?
require_once("cms/core/helper/bean/Abstract.php");
require_once("cms/project/om/ProjectPeer.php");
require_once("cms/project/om/ProjectI18nPeer.php");
require_once("cms/core/om/CountryPeer.php");

class PHP_CMS_View_Helper_Projects extends AbstractList {

    public function projects($form=null) {

        if($this->isInit)
            return $this;

        parent::init($form);

        $this->criteria->add(ProjectPeer::CATEGORY_ID,
            $form->getId());

        if(strlen($form->getLanguage()) > 0)
            $this->criteria->add(ProjectI18nPeer::LANGUAGE_CODE,
                $form->getLanguage());


        if(strlen($form->getQuery()) == 0 && strlen($form->getLanguage()) == 0)
            $this->criteria->add(
                ProjectI18nPeer::LANGUAGE_CODE,
                $this->param(_Core::DEFAULT_LANGUAGE)
            );

        $this->criteria->addJoin(ProjectI18nPeer::PROJECT_ID, ProjectPeer::PROJECT_ID);

        return $this;

    }


    /**
     * Define the propel method we are going to use to list
     * page items.
     */
    public function getMethod() {
        return "doSelectJoinAll";
    }


    /**
     * Define the propel peer we are going to use to list
     * page items.
     */
    public static function getPeer() {
        return new ProjectI18nPeer();
    }


    /**
     * Return the searchable fields for this list page.
     */
    public static function getFields() {
        return array(
            ProjectPeer::URL,
            ProjectPeer::DATE,
            ProjectI18nPeer::NAME,
            ProjectI18nPeer::INTRO,
            ProjectI18nPeer::DESCRIPTION,
            ProjectI18nPeer::INSERT_DATE,
            ProjectI18nPeer::MODIFIED_DATE
        );
    }
}
?>